Make an assignment reactive without $: if it has reactive dependencies#70
Make an assignment reactive without $: if it has reactive dependencies#70bomzj wants to merge 1 commit intosveltejs:masterfrom
Conversation
|
|
By doing this, Svelte will be changing a standard javascript behavior. The migration from v3 may be kinda painful because devs will need to review all existing components to see if the reactive approach is intended, and if not, he won't be able to have a mutable non-reactive variable. I think this change has little to add to compensate the tradeoff mentioned above. |
|
No, it'll break a code pattern I've seen used in several different libraries. <script>
let value = ...;
let oldValue = value;
$: {
// do something with value and oldValue
oldValue = value;
}
</script>Your proposal breaks the assumption that |
Make an assignment reactive without $: if it has reactive dependencies
Summary
Motivation
This is how we do now
And this is how it can be
In case if we need one time
doubledto be non reactive we could define it like